<script type="text/html" template lay-done="layui.data.done(d);">
    <div class="layui-form coreshop-form layui-form-pane" lay-filter="LAY-app-CoreCmsWeChatPayConfig-createForm" id="LAY-app-CoreCmsWeChatPayConfig-createForm">


        <div class="layui-form-item">
            <label for="appType" class="layui-form-label  layui-form-required">应用类型</label>
            <div class="layui-input-inline layui-inline-5">
                <select name="appType" lay-verify="required" placeholder="请输入应用类型" lay-reqText="请输入应用类型">
                    <option value="">请选择所属应用类型</option>
                    {{# layui.each(d.params.data.weiChatPayTradeType, function(index, item){ }}
                    <option value="{{ item.title }}">{{ item.description }}</option>
                    {{# }); }}
                </select>
            </div>
            <label for="appId" class="layui-form-label  layui-form-required">应用AppID</label>
            <div class="layui-input-inline layui-inline-5">
                <input name="appId" lay-verify="required" class="layui-input" placeholder="请输入应用号" lay-reqText="请输入应用号" />
            </div>
            <label for="mchId" class="layui-form-label  layui-form-required">商户号</label>
            <div class="layui-input-inline layui-inline-5">
                <input name="mchId" lay-verify="required" class="layui-input" placeholder="请输入商户号" lay-reqText="请输入商户号" />
            </div>
        </div>

        <div class="layui-form-item">
            <label for="apiKey" class="layui-form-label  layui-form-required">API秘钥</label>
            <div class="layui-input-inline layui-inline-12">
                <input name="apiKey" lay-verify="required" class="layui-input" placeholder="请输入API秘钥" lay-reqText="请输入API秘钥" />
            </div>
            <div class="layui-form-mid">
                apiV2密钥
            </div>
        </div>

        <div class="layui-form-item">
            <label for="apiV3Key" class="layui-form-label">APIv3密钥</label>
            <div class="layui-input-inline layui-inline-12">
                <input name="apiV3Key" class="layui-input" placeholder="请输入APIv3密钥" lay-reqText="请输入APIv3密钥" />
            </div>
            <div class="layui-form-mid">
                只有开启了商家付款到零钱的功能才需要录入APIv3密钥（用于提现）
            </div>
        </div>

        <div class="layui-form-item layui-form-text">
            <label for="certificate" class="layui-form-label layui-form-required">
                微信支付商户p12证书，请选择【apiclient_cert.p12】文件
                <button type="button" class="layui-btn layui-btn-xs layui-btn-danger" id="doUpload">
                    <i class="layui-icon">&#xe67c;</i>上传证书
                </button>
            </label>
            <div class="layui-input-block">
                <textarea name="certificate" id="certificateBox" lay-verify="required" placeholder="请选择【apiclient_cert.p12】文件" class="layui-textarea"></textarea>
            </div>
        </div>

        <div class="layui-form-item">
            <label for="rsaPublicKey" class="layui-form-label">RSA公钥</label>
            <div class="layui-input-inline layui-inline-8">
                <input name="rsaPublicKey" class="layui-input" placeholder="请输入RSA公钥" lay-reqText="请输入RSA公钥" />
            </div>
            <div class="layui-form-mid">
                目前仅"企业付款到银行卡API"使用，调用"获取RSA加密公钥API"即可获取
            </div>
        </div>

        <div class="layui-form-item">
            <label for="subAppId" class="layui-form-label">子商户应用号</label>
            <div class="layui-input-inline layui-inline-4">
                <input name="subAppId" class="layui-input" placeholder="请输入子商户应用号" lay-reqText="请输入子商户应用号" />
            </div>
            <div class="layui-form-mid">
                目前仅调用服务商API时使用，子商户的公众号、移动应用AppId。
            </div>
        </div>
        <div class="layui-form-item">
            <label for="subMchId" class="layui-form-label">子商户号</label>
            <div class="layui-input-inline layui-inline-4">
                <input name="subMchId" class="layui-input" placeholder="请输入子商户号" lay-reqText="请输入子商户号" />
            </div>
            <div class="layui-form-mid">
                目前仅调用服务商API时使用，子商户的商户号。
            </div>
        </div>

        <div class="layui-form-item">
            <label for="notifyUrl" class="layui-form-label layui-form-required">支付回调通知</label>
            <div class="layui-input-inline layui-inline-8">
                <input name="notifyUrl" lay-verify="required" class="layui-input" placeholder="请输入支付回调通知" lay-reqText="请输入支付回调通知" value="https://api.pro.demo.corecms.cn/Notify/WeChatPay/Unifiedorder" />
            </div>
            <div class="layui-form-mid">
                接口地址+【/Notify/WeChatPay/Unifiedorder】
            </div>
        </div>

        <div class="layui-form-item">
            <label for="refundUrl" class="layui-form-label  layui-form-required">退款回调</label>
            <div class="layui-input-inline layui-inline-8">
                <input name="refundUrl" lay-verify="required" class="layui-input" placeholder="请输入退款回调" lay-reqText="请输入退款回调" value="https://api.pro.demo.corecms.cn/Notify/WeChatPay/Refund" />
            </div>
            <div class="layui-form-mid">
                接口地址+【/Notify/WeChatPay/Refund】
            </div>
        </div>

        <div class="layui-form-item">
            <label for="jumpUrl" class="layui-form-label">跳转地址</label>
            <div class="layui-input-inline layui-inline-8">
                <input name="jumpUrl" class="layui-input" placeholder="请输入跳转地址" lay-reqText="请输入跳转地址" />
            </div>
            <div class="layui-form-mid">
                H5，PC端支付成功或者支付失败后跳转的查询支付状态的地址。
            </div>
        </div>

        <div class="layui-form-item">
            <label for="isEnable" class="layui-form-label  layui-form-required">是否开启</label>
            <div class="layui-input-inline layui-inline-4">
                <input type="checkbox" lay-filter="switch" name="isEnable" lay-skin="switch" lay-text="开启|关闭">
            </div>
            <label for="isDefault" class="layui-form-label  layui-form-required">是否本类默认</label>
            <div class="layui-input-inline layui-inline-4">
                <input type="checkbox" lay-filter="switch" name="isDefault" lay-skin="switch" lay-text="开启|关闭">
            </div>
        </div>

        <div class="layui-form-item text-right core-hidden">
            <input type="button" class="layui-btn" lay-submit lay-filter="LAY-app-CoreCmsWeChatPayConfig-createForm-submit" id="LAY-app-CoreCmsWeChatPayConfig-createForm-submit" value="确认添加">
        </div>
    </div>
</script>
<script>
    var debug = layui.setter.debug;
    layui.data.done = function (d) {
        //开启调试情况下获取接口赋值数据
        if (debug) { console.log(d.params.data); }
        layui.use(['admin', 'form', 'laydate', 'upload', 'coreHelper', 'cropperImg'],
            function () {
                var $ = layui.$
                    , form = layui.form
                    , admin = layui.admin
                    , laydate = layui.laydate
                    , upload = layui.upload
                    , cropperImg = layui.cropperImg
                    , coreHelper = layui.coreHelper;

                var upload = layui.upload;

                //执行实例
                upload.render({
                    elem: '#doUpload' //绑定元素
                    , auto: false
                    , accept: 'file'
                    , exts: 'p12'
                    , choose: function (obj) {
                        obj.preview(function (index, file, result) {
                            var base64 = result.substring(result.indexOf(',') + 1)
                            $('#certificateBox').val(base64);
                            form.render(null, 'LAY-app-CoreCmsWeChatPayConfig-createForm');
                        });
                    }, error: function () {
                        //请求异常回调
                    }
                });

                form.verify({

                });
                //重载form
                form.render(null, 'LAY-app-CoreCmsWeChatPayConfig-createForm');
            })
    };
</script>
